package com.example.a313ldy.yuejian_17.Activity;


import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import android.widget.Toast;

import com.example.a313ldy.yuejian_17.Bean.StringBean;
import com.example.a313ldy.yuejian_17.Listener.UserListener;
import com.example.a313ldy.yuejian_17.Model.UserModel;
import com.example.a313ldy.yuejian_17.R;



/**
 * Created by LDY on 2017/9/30.
 */
public class RegisterActivity extends AppCompatActivity implements View.OnClickListener, UserListener {
    public Button btn_register;
    public Button login;
    public EditText teleNumber;
    public EditText password;
    public EditText CN_name;
    String phone;
    String pwd;
    String cn_name;

    /**
     * ATTENTION: This was auto-generated to implement the App Indexing API.
     * See https://g.co/AppIndexing/AndroidStudio for more information.
     */


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.registe);
        teleNumber = (EditText) findViewById(R.id.teleNumber);
        password = (EditText) findViewById(R.id.password);
        CN_name = (EditText) findViewById(R.id.CN_name);
        btn_register = (Button) findViewById(R.id.btn_register);
        btn_register.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.btn_register:
                phone = teleNumber.getText().toString();
                pwd = password.getText().toString();
                cn_name = CN_name.getText().toString();
                UserModel usermodel = new UserModel();
                usermodel.getRegister(phone, pwd,cn_name ,this);
                break;
        }
    }

    //这个方法是在Model中调用的
    @Override
    public void onResponse(StringBean stringBean) {
        Toast.makeText(this, "注册成功!", Toast.LENGTH_SHORT).show();
    }


    @Override
    public void onFail(String msg) {
        Toast.makeText(this, "" + msg, Toast.LENGTH_SHORT).show();
    }

}
